package cate.game.activity.dailyrecharge.msg;

import cate.game.GameBody;
import cate.game.activity.dailyrecharge.RechargeAddUpActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBRechargeAddUpActivity;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "累计充值活动领取奖励 请求")
public class RechargeAddUpGetRewardReq implements MsgInput {
    @NoteField("功能ID")
    public int funcId;
    @NoteField("配置ID")
    public int tid;

    @Override
    public MsgConfig conf() {
        return MsgIdBRechargeAddUpActivity.RECHARGE_ADD_UP_GET_REWARD_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        RechargeAddUpActivity single = cc.getRole().getActivity().getActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        EcResult<RechargeAddUpActivity> r = single.getReward(tid);
        if (r.ok()) {
            r.data.noticeUpdate();
        } else {
            game.notice.message(cc.getRole(), r);
        }
    }
}
